package easy.只出现一次的数字;


public class Solution {
    public int singleNumber(int[] nums) {
        int single = 0;
        for (int num : nums) {
            single ^= num;
        }
        return single;
    }

    public static void main(String[] args) {
        int[] nums = {1, 2, 2};
        int[] nums2 = {4, 1, 9, 1, 9};
        Solution solution = new Solution();
        System.out.println(solution.singleNumber(nums));
        System.out.println(solution.singleNumber(nums2));
    }
}
